﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BigLotterySyndicate.Classes;
using SyndicateBusiness.Classes;

namespace BigLotterySyndicate.MyAccount.Controls
{
    public partial class TopNav : BaseUserControl
    {
        protected const string SelectedNavSectionPageParam = "Ns";

        public enum AdminNavSection
        {
            Home = 0,
            History =1
        }

        public AdminNavSection NavSelectedSection
        {
            get
            {
                if (this.ViewState["Ns"] == null)
                {
                    if (this.Request[SelectedNavSectionPageParam] != null)
                        this.NavSelectedSection = (AdminNavSection)Utilities.StringToInt(this.Request[SelectedNavSectionPageParam], 0).Value;
                    else
                        this.NavSelectedSection = AdminNavSection.Home;
                }

                return (AdminNavSection)this.ViewState["Ns"];
            }
            set
            {
                this.ViewState["Ns"] = value;
            }
        }

        protected string PrintCssClassIfSelected(AdminNavSection section, string cssClass)
        {
            return this.NavSelectedSection == section ? cssClass : "";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.BasePage.IsUserLoggedIn)
            {
                this.PlaceHolderAdmin.Visible = this.BasePage.IsAdmin;
            }
        }
    }
}